var app = getApp();

Page({
    data: {
        is_show_share: !1,
        _is_load: !1,
        is_akey: !1,
        bd_akey: !1,
        cardid: "",
        bjid: ""
    },
    onLoad: function(a) {
        var t = this, e = a.card_id;
        t.setData({
            t_card_id: e
        }), wx.setTopBarText({
            text: "名片通信录"
        }), app.util.getUserInfo(function(a) {
            t.setData({
                userInfo: a
            }), a.memberInfo || wx.showModal({
                title: "重要提示",
                content: "你【拒绝】了授权，不能和您一起快乐的玩耍了！请10分钟后再次点击授权，或者删除小程序重新进入，点击【允许】",
                showCancel: !1,
                success: function(a) {
                    wx.navigateBack();
                }
            });
        }), app.util.request({
            url: "entry/wxapp/GetCard",
            data: {
                m: "bbyscm_card"
            },
            success: function(a) {
                0 == a.data.errno && 0 != a.data.data && (0 == a.data.data.akey ? wx.showModal({
                    title: "重要提示",
                    content: "你已经绑定了名片！不能重复绑定！",
                    showCancel: !1,
                    success: function(a) {
                        wx.navigateBack();
                    }
                }) : t.setData({
                    is_akey: !0
                }));
            }
        }), app.util.request({
            url: "entry/wxapp/GetCardTr",
            data: {
                m: "bbyscm_card",
                card_id: e
            },
            success: function(a) {
                0 == a.data.errno ? 0 == a.data.data.akey ? a.data.data.curr_openid == a.data.data.openid ? wx.switchTab({
                    url: "../index/index"
                }) : a.data.data.openid ? (t.setData({
                    card_info: a.data.data,
                    cardname: a.data.data.cardname,
                    bd_akey: !0,
                    _is_load: !1
                }), wx.setNavigationBarTitle({
                    title: a.data.data.cardname + "的名片"
                })) : t.setData({
                    card_info: a.data.data,
                    cardname: a.data.data.cardname,
                    mbd_akey: !0,
                    _is_load: !1
                }) : t.setData({
                    _is_load: !1,
                    is_akey: !0
                }) : t.setData({
                    _is_load: !1,
                    is_load_more: !0
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    postCard: function(a) {
        this.setData({
            btn_disabled: !0,
            submitIsLoading: !0
        }), JSON.stringify(a.detail.value);
        var t = a.detail.formId, e = a.currentTarget.id;
        wx.showToast({
            title: "提交中...",
            icon: "loading",
            duration: 2e3
        }), app.util.request({
            url: "entry/wxapp/PostCardBp",
            data: {
                m: "bbyscm_card",
                form_id: t,
                cardid: e
            },
            method: "POST",
            success: function(a) {
                0 == a.data.errno ? wx.showModal({
                    title: "提示",
                    content: "提交绑定成功",
                    showCancel: !1,
                    success: function(a) {
                        wx.redirectTo({
                            url: "/pages/card/index/index"
                        });
                    }
                }) : wx.showModal({
                    title: "提示",
                    content: a.data.message,
                    showCancel: !1,
                    success: function(a) {
                        a.confirm;
                    }
                });
            },
            fail: function(a) {
                wx.showModal({
                    title: "提示",
                    content: a.data.message,
                    showCancel: !1,
                    success: function(a) {
                        a.confirm;
                    }
                });
            },
            complete: function() {
                wx.hideToast();
            }
        });
    }
});